package com.swipemaster.common;

/** Public static functions related to coordinates system. */
public class Coords
{
	public static int distance(int x, int y, int x2, int y2)
	{
		final int dx = x - x2;
		final int dy = y - y2;
		return (int) Math.round(Math.sqrt((dx * dx) + (dy * dy)));
	}

	/** Multiply by diagonal length.
	 * @param d Length or speed in universal units.
	 * @return Length or speed in screen units. Length in px. Speed in px per ms. */
	public static double mulByDiag(double d)
	{
		return d * Global.app.consts.diagonal;
	}

	public static int pythagoras(int a, int b)
	{
		return (int) Math.round(Math.sqrt((a * a) + (b * b)));
	}

	/** Get screen x.
	 * @param x X in universal units.
	 * @return X in px. */
	public static int x(double x)
	{
		return (int) Math.round(x * Global.app.consts.width);
	}

	/** Get screen y.
	 * @param y Y in universal units.
	 * @return Y in px. */
	public static int y(double y)
	{
		return (int) Math.round(y * Global.app.consts.height);
	}
}